#include "heightmap.h"
#include "image_file.h"
#include "canvas.h"

using namespace krryn::view;

void heightmap::generate(){
	image_file_bmp l_File(m_Filename);
	canvas *l_Canvas = l_File.load();
	pixel_t *l_Buffer = l_Canvas->get_buffer();
	m_Width = l_Canvas->get_width();
	m_Depth = l_Canvas->get_height();
	m_HeightPoints = new float[m_Width * m_Depth];

	float *l_HeightPoints = m_HeightPoints;
	for(int i = 0; i < m_Width * m_Depth; i++){
		*l_HeightPoints++ = (*l_Buffer++ & 0xFF) / 256.f;
	}

	delete l_Canvas;
}
